package com.dayu.tcp.common.encrypt;

import lombok.Getter;

import java.nio.charset.Charset;

public class InvalidEncrypt implements Encrypt {

    private InvalidEncrypt() {
    }

    @Getter
    private static final InvalidEncrypt instance = new InvalidEncrypt();

    @Override
    public byte[] encrypt(byte[] src) {
        return src;
    }

    @Override
    public byte[] decrypt(byte[] src) {
        return src;
    }

    @Override
    public String encrypt(String src, Charset charset) {
        if (charset == null) {
            charset = Charset.defaultCharset();
        }
        return new String(encrypt(src.getBytes(charset)));
    }

    @Override
    public String decrypt(String src, Charset charset) {
        if (charset == null) {
            charset = Charset.defaultCharset();
        }
        return new String(decrypt(src.getBytes(charset)));
    }
}
